## Note that there is much that is pessimal in this code. I haven't the
## time to optimize and take out a lot of obvious problems. However,
## even in its current dainbramaged form, this program should prove
## useful. The slowness of the code is actually a feature. :-)
##
## The biggest remaining problems at the moment are:
## 1) distribution of the zipcode file, 2) handling ranges
## in the zipcode file, 3) not enough variation, and 4) it gives up very
## easily on 'odd' names, and yet much oddness gets though anyway.
##
## Problems with this program should be posted to the newsgroup
## alt-current-events.net-abuse, with 'fletch' in the subject line.
##
## Syntax: fletch [-q] (the -q flag reduces excess verbosity.)
##
##
# *!*!*!* USER DEFINITIONS *!*!*!*
#
# Set the following to the root level of your news spool. This program
# does not work for machines with only nntp feeds.
SPOOL=/usr/spool/news
#
# The default newsgroup to scan. The best results can be obtained
# by scanning mostly regional groups with 1 or 2 big 7 groups.
DEFGROUP=alt.usenet.kooks
#
#
# A temporary place to store files. You can also store the zipcode
# file here so that you only need one copy of it on the system. YMMV.
TMPDIR=/usr/tmp
#
#
# This must point to the location of the zipcode file. Directions for
# finding and building a zipcode file are located at the top of the script.
# Keep your eyes on the net in case someone builds a better zipcode
# file. There are a few problems with the one described above.
ZIPFILE=$HOME/.fletch.zips
#
#
# GNU -- g'use 'em if you gots 'em!
#
PERL=perl
AWK=awk
GREP=grep
SED=sed
SORT=sort
UNIQ=uniq
TOUCH=touch
ECHO=echo
#
#
BNFILE=$TMPDIR/fl.$USER.tmp1.$$
TMFILE=$TMPDIR/fl.$USER.tmp2.$$
FNFILE=$HOME/.fletch.fn
LNFILE=$HOME/.fletch.ln
#
#
# More common items are multiply listed. Add a few if you wish.
#
ROADS="Road Rd. Rd road Street St. street St Avenue Ave. Av. Av Boulevard Blvd. Lane Ln. Road Road Road Road Rd. Rd. Street St. St. St. St. Ave. Circle"
#
#
# Here we go...
#
# how do I echo without newline??
if [ `( $ECHO -n foo ; $ECHO bar ) | wc -l | $AWK '{print $1}'` = "1" ]
then
En="-n"
Ec=""
else
En=""
Ec="\\c"
fi
if [ $# -gt 0 ]
then case $1 in
-q*) quiet=true ;;
esac
fi
if [ ! -f $ZIPFILE ]
then
$ECHO "I'm sorry, I can't find the zipcode file. It's"
$ECHO " supposed to be in $ZIPFILE. Please read the comments"
$ECHO " at the beginning of this script, and follow the directions"
$ECHO " there."
exit 1
fi
if [ -f $FNFILE -a -f $LNFILE ]
then
fncount=`< $FNFILE wc -l | awk '{print $1}'`
lncount=`< $LNFILE wc -l | awk '{print $1}'`
[ -z "$quiet" ] && $ECHO "I find $fncount first names, and $lncount last names."
else
mustscan=true
fncount=0 ; lncount=0
$ECHO
$ECHO "For best results, use mostly your local and regional newsgroups"
$ECHO " plus 1 or 2 of the big 7 newsgroups. Try to have at least a"
$ECHO " few hundred names in the database."
$ECHO
fi
if [ -n "$mustscan" ]
then doscan=true
else
if [ -z "$quiet" ]
then
$ECHO $En "Do you wish to scan for more names? [no] " $Ec
read ans
case $ans in
y*) doscan=true;;
esac
fi
fi
if [ -n "$doscan" ]
then
$ECHO
$ECHO $En "What group should I scan for names? [$DEFGROUP] " $Ec
read GROUPNAME
[ -z "${GROUPNAME}" ] && GROUPNAME=$DEFGROUP
GROUP=`$ECHO $GROUPNAME | sed 's/\./\//g'`
if [ ! -d ${SPOOL}/$GROUP ]
then
$ECHO "I can't find $GROUPNAME. Check \$SPOOL. Bailing out."
exit 1
fi
$ECHO "Now scanning $GROUPNAME for names... (This may take a few minutes)"